package com.huluobo.a2204parkdemo.park

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.bean.ParkingBean
import com.huluobo.base.bean.ParkingBeanItem
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import retrofit2.http.Body
import javax.inject.Inject

/**
 *  Created by LC on 2024/8/22.
 */
@HiltViewModel
class ParkViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val queryParkSuccess by lazy { MutableLiveData<String>() }

    fun queryAllParking() {
        executeNetRequest(
            { apiService.queryAllParking() },
            queryParkSuccess::postValue
        )
    }

    val color by lazy { MutableLiveData<String>() }

    fun getColor() {
        executeNetRequest(
            { apiService.getCarColor() },
            color::postValue
        )
    }

    val addParkingSuccess by lazy { MutableLiveData<String>() }
    fun addParking(body: RequestBody) {
        executeNetRequest(
            { apiService.addParking(body) },
            addParkingSuccess::postValue
        )
    }
}